package com.aaa.mks.controller;

import com.aaa.common.util.Result;
import com.aaa.mks.entity.Advertise;
import com.aaa.mks.service.AdvertiseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 广告位(Advertise)表控制层
 *
 * @author makejava
 * @since 2020-11-26 21:09:39
 */
@RestController
@RequestMapping("advertise")
public class AdvertiseController {
    /**
     * 服务对象
     */
    @Resource
    private AdvertiseService advertiseService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Result selectOne(Long id) {
        return this.advertiseService.queryById(id);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @GetMapping("deleteById")
    public Result deleteById(Long id){
        return advertiseService.deleteById(id);
    }

    /**
     * 分页加各种条件查询
     * @param pageNo
     * @param pageSize
     * @param advertise
     * @return
     */
    @GetMapping("queryPageByParam")
    public Result queryPageByParam(Integer pageNo, Integer pageSize, Advertise advertise){
        return advertiseService.queryPageByParam(pageNo,pageSize,advertise);
    }

    /**
     * 新增or修改
     *
     * @param advertise 实例对象
     * @return 实例对象
     */
    @GetMapping("insertOrUpdate")
    public Result insertOrUpdate(Advertise advertise){
        return advertiseService.insertOrUpdate(advertise);
    }
}